package com.yvon.core;

import com.yvon.core.pojo.TreeEntity;
import com.yvon.core.result.CommonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author : Yvon
 * @since : 2021-06-29
 */
public abstract class BaseTreeController <E extends TreeEntity, D, V, S extends BaseTreeService<E>> extends BaseCrudController<E, D, V ,S>{

    @Autowired
    private S baseService;

    public BaseTreeController() {
    }

    @GetMapping({"/children/{id}"})
    @ApiOperation(
            value = "根据编号查询子节点",
            notes = "根据编号查询子节点API"
    )
    public CommonResult<D> getChildrenById(@PathVariable("id") String id) {
        E entity = this.baseService.getChildrenById(id);
        return this.success(this.entityToDto(entity));
    }
}
